require 'crawler/crawler'
require 'uri'


module Crawler
  
  class FlickrCrawler < Crawler
    
    public 
    
    
    def initialize(options = {})
      super options
    end
    
    def crawl_table
      FlickrCrawl
    end
    
    def service_name
      'flickr'
    end
    
    protected
    
    def crawl(c)
      if c.service.user_url_on_service =~ /http:\/\/www\.flickr\.com\/photos\/[^\/]*\// then
        request_uri = URI.parse c.service.user_url_on_service.gsub(/photos/, 'people')
        @curl.url = request_uri.to_s
        @curl.http_get
        c.status = @curl.response_code
        c.body = @curl.body_str
        response = @curl.response_code == 200
      else
        c.body = "user_url_on_servic dosn't match"
        c.status = 102
        response = false
      end

      response
    end
    
    def has_crawl?(s)
      !s.flickr_crawl.nil?
    end
    
  end
  
end #module Crawler